The invention relates to a method for protection against fraudulent modification of data sent by a user to a secure medium (a smart card for example). Such data can be constituted by a command and/or a message accompanied by an electronic signature for its authentication. The invention should be seen in a context where the secure medium is coupled to a PC (Personal Computer, designating a home computer) via a reader.
With the development of electronic commerce, whether company to company or company to private individual, the necessity is appearing of achieving a legal framework allowing any disputes to be resolved before a court. This legal framework is starting to be put in place, whether in Europe or the United States, with the recognition of the electronic signature as a means of proof.
Under these conditions, it is important to consider the technical means to be implemented for generating reliable electronic signatures, that is to say those which are the least disputable possible. Generally, use is made of public key cryptography techniques which make it possible to generate digital signatures for digital documents. The majority of the cryptography algorithms commonly used, such as DSA, Schnorr or El Gamal for example, make use of a hash function in the electronic signature generation method. Such a pseudo-random function consists of converting the initial text to be signed into a hashed text which breaks the linearity of the signature generation.
Electronic signature generation algorithms are generally installed using hardware and software, conventionally a PC provided with software and the public key, and a secure medium containing the secret key of the user and the cryptographic signature algorithms.
According to application, the secure medium can be a smart card or a PCMCIA card for example. The majority of portable PCs are provided with a PCMCIA integrated reader. Certain of these cards in the PCMCIA format can even be smart card readers.
It is assumed subsequently that the electronic signature is generated from a smart card requiring the use of an authentication code (PIN code) and that the reader is a very simple coupler of the GemPC420 type having neither keyboard nor screen. This is because readers with such inputs/outputs (of the GCR500 type) are much more expensive and are rarely found connected to a PC since they are standalone, but the implementation of the invention would however be facilitated by their use.
Conventionally, it is considered that an electronic signature generation method must produce a signature having the following properties:                Authenticity: a valid signature implies the deliberate wish of the user to sign the document with which the signature is associated. The signature protocol must therefore guarantee the active participation of the user and of him alone. Consequently it is necessary to authenticate said user prior to the signing. In a system using a smart card, two elements guarantee the active presence of the user: the presence of a physical element which he alone possesses (the card) and the input of data which he alone knows (a PIN code or a password).        Impossibility of falsification: only the user must be in a position to generate a signature for a given document. This property is guaranteed by the use of cryptographic algorithms considered as secure and of a reliable public key infrastructure, as well as by the use of a means for storing the keys which is resistant to physical and logical attacks (a smart card for example).        Non-reusability: the signature associated with a document cannot be reused and associated with another document, that is to say it must be possible to detect any modification of the message associated with the signature. This property is guaranteed by the known methods using a hash function and algorithms for generating random digital signatures by calling upon random numbers regenerated between each signature.        Non-repudiation: the user of the document cannot deny having deliberately signed a document after having done so. This property depends on the overall security of the system, and is therefore true only if the probability of attacking the system is negligible. In the contrary case a user can repudiate his signature by putting forward the weakness of the system as an argument. It must be noted that first party attacks must be taken into account at that level.        
This is because a user can deliberately introduce a flaw into the system in order to be able, a posteriori, to repudiate his signature. For example, if the user himself generates his public key, he can deliberately choose a weak key while subsequently claiming to have chosen a key at random which proved to be weak and has been cracked.
It is considered, in general, that systems using a PC and smart cards are sufficiently reliable to guarantee the non-repudiable nature of generated signatures. However, attacks by means of Trojan horses have developed sufficiently lately for this point of view to be legitimately questioned.
A Trojan horse is defined as a malicious code section which conceals itself in a program performing commonplace tasks.
The operating systems currently used on home PCs, as well as the lack of vigilance of users, means that it is very easy to introduce a program including a Trojan horse into a PC and that the Trojan horse, once in place, has all possible rights. Thus, for example, Trojan horses can be concealed in popular and freely available programs or in shareware on the Internet such as screen savers for example. There are also generic Trojan horses such as “Back Orifice” which make it possible to take total control of a remote PC and to modify all or some of its content, or Trojan horses which exploit an error (bug) in a network program (for example Internet Explorer).
There are numerous attacks which can be carried out by Trojan horses, but three main ones will be considered:                Theft of the PIN code of the user: the PIN (Personal Identification Number) code constitutes an authentication value allowing the card holder to be authenticated.        
A Trojan horse, installed somewhere in the operating system, in an applications software package, in the card reader drivers or in the drivers specific to the card, is in a position to copy the PIN code which is entered by the user and transmit it to the originator of the Trojan horse. Subsequently, all that remains is for said originator to steal the card from its legitimate owner and use it without his knowledge.                Modification of a command issued by the user destined for the card.        
For example, such an attack can be carried out at the time of a request for generating a key on board the card by the PC. The Trojan horse can intercept this command, itself generate a key, customise the card with this key and transmit a copy thereof. In such a case, it is obvious that the properties associated with the electronic signature are lost, since the owner of the card is no longer the only one able to produce a valid signature.                Modification of the document to be signed between its viewing by the user and its signing by the card.        
When the user enters his PIN code in order to signify his approval, the applications software transmits the document to be signed to the card which hashes it before signing it (the context here is one where the volume of data to be signed is not incompatible with the processing capabilities of a smart card).
However, a Trojan horse can intercept the data transmitted to the card and modify them. The user will then have signed a document which he will not only not have approved, but also never seen. It is clear that such a situation is not acceptable. It then becomes obvious that, with electronic commerce and electronic signatures becoming widespread, such attacks can be used as an argument for refuting signatures.
The particular problem of theft of the PIN code is today taken into account and mastered in systems integrating modern smart card readers like for example the GemPC420. Such a reader, shown schematically in FIG. 1, has a specific mechanism, commonly referred to as a “trusted path” or computer security secure path, intended to avoid PIN code theft by a Trojan horse.
FIG. 1 depicts the principle of operation of the GemPC420. This is placed between the PC and the keyboard. It is therefore in a position to interrupt all communications between the keyboard and the PC. The reader has three modes of operation, corresponding to three communication circuits between the PC, the keyboard and the smart card reader. These circuits are numbered 1 to 3 in FIG. 1.
Circuit 1 corresponds to a mode of operation where the card is not used and where the PC dialogues with the keyboard. Circuit 2 corresponds to a mode of operation where the PC dialogues with the card by means of the APDU (Application Protocol Data Unit) defined by the ISO standard for standardising exchanges between a reader and a card. Finally, circuit 3 corresponds to the trusted path: the reader cuts communication between the PC and the keyboard and the keys pressed by the user are sent directly to the card by the reader. The reader goes into mode 3 on the order of the PC and then completes the APDU sent to the card by the PC with the codes of the keys pressed by the user.
For more security and ease of use, a light emitting diode (LED) flashes on the reader to signify that the latter is in mode 3, and only in that case.
A Trojan horse is therefore unable to intercept the PIN code of the user, since this code does not at any time pass through the PC. The user must enter his PIN code only when the reader is in trusted path mode indicated by the flashing LED. This is because a Trojan horse can display a message on the screen inviting the user to enter his PIN code without, for all that, switching the reader into trusted path mode. In this case, the reader would not cut the keyboard to reader communication and the Trojan horse would obtain the PIN code.
In conclusion, it is clear that the GemPC420 card reader solves the problem of theft of the PIN code by a Trojan horse. There also exist other readers, using other technologies, which can achieve the same results.
Use can be made for example of readers using the USB (Universal Serial Bus) communication protocol on a computer equipped with a USB keyboard (like for example the Apple computers). The principle is very similar to that described previously: the card reader possesses two USB connectors. The first connects to one of the USB ports of the computer and the second is used for connecting the keyboard. In normal circumstances, the reader transmits the information exchanged between the keyboard and the computer. When it receives an isolation command on its channel, the reader cuts the connection between the keyboard and the PC. The information which is then typed on the keyboard is not sent to the computer but used directly by the reader. A PIN code entered in this way therefore never enters the PC and thus does not risk being the target of a Trojan horse.
In the remainder of this document, the starting principle is that the solution uses a GemPC420 reader, but it is clear that any other reader having a trusted path, like for example a USB reader which has just been described, can also be used.
Besides the problem of theft of the PIN code, there remains to be solved the problem of modification of a command and/or of a document to be signed.
At the moment, a Trojan horse present for example in a reader driver can modify the document sent to the card for signature after acceptance thereof by the user. For example the document “I the undersigned X acknowledge that I owe FF10 to Y” can be changed by the Trojan horse into “I the undersigned X acknowledge that I owe FF10000 to Y”.
A Trojan horse can also modify a command, for example by itself generating a key of which it keeps a copy and sending the order to the card to store this key, instead of sending the order to the card to generate an on-board key.